package com.haoshuang.zhouzhoubang.ui.vm

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData


class AgainDoorInViewModel : BaseViewModel() {

    /**
     * 二次上门
     */
    val orderSecondVisitData = StatefulMutableLiveData<Any>()
    fun orderSecondVisit(
        id: String?,
        service_day: String?,
        service_time: String?,
        content: String?,
        image: String?,
        money: String?,
        type: String?
    ) = netRequest {
        start { orderSecondVisitData.value = StateData.Loading }
        request {
            ApiRepo.orderSecondVisit(
                id,
                service_day,
                service_time,
                content,
                image,
                money,
                type
            )
        }
        success { orderSecondVisitData.value = StateData.Success(it) }
        error { code, msg ->
            orderSecondVisitData.value = StateData.Error(code, msg)
        }
    }

}